<%@ page language="java" import="java.util.*" import="java.text.SimpleDateFormat" pageEncoding="UTF-8"%>
<%@ page import="com.bluesky.light.staff.*"%>
<%
	request.setCharacterEncoding("utf-8");
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
	// check if the user is login
	Staff s = (Staff)session.getAttribute("staff");
	if (s == null) {
		response.sendRedirect("index.jsp");
	}	
	String name = s.getName();
%>
<%
	
	String action = request.getParameter("action");
	
	if (action != null && action.trim().equals("changeinfo")) {

		name = request.getParameter("name");
		String idcard = request.getParameter("idcard");
		String username = request.getParameter("username");

		
		Calendar cal = Calendar.getInstance();
		cal.clear();
		
		s.setUsername(username);
		s.setName(name);
		s.setIdcard(idcard);
		StaffService.getInstance().update(s);
		response.sendRedirect("staff_infoModify.jsp");
		return;
	}
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>light - change info</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="css/main.css" rel="stylesheet" type="text/css" />

			<script language=JavaScript  src="staff/js/checkstaffinfo.js"> 
	</script>
	
  </head>
  
  <body>
	<!-- header -->
	<div id="header">
		<div id="logo"><img src="images/logo_small2.png"/></div>
	</div>
	<!-- // header -->
	<!-- nav -->
	<div id="nav">
	</div>
	<!-- // nav -->
	<!-- container -->
	<div id="container">
		<!-- contents -->
		<div id="contents">
	    	<div id="menu">
	        	<div id="user_info">
	            		<img src="develop/user_icon.jpg"/> 
	            		<b>Finance</b>
	           		</div>
	           		<div>
	           		<%=name%>
	           		</div>
	           		<div>
	            	<%SimpleDateFormat sdf = new SimpleDateFormat("EEE, yyyy-MM-dd", new Locale("US"));%><%=sdf.format(new Date())%><br></br>
	            	</div>
	        	<ul>
	            	<li><a href="finance/home.jsp"><img src="images/news.png" /> Health News</a></li>
					<li><a href="finance/staff_userSearch.jsp"><img src="images/surscribe.png" /> User search</a></li>
						<li><a href="finance/staff_infoModifyInput.jsp"><img src="images/account.png" /> Account Management</a></li> 
						<li><a href="finance/staff_infoModifyInput.jsp">Change info</a></li>
						<li><a href="finance/staff_pwdModifyInput.jsp">Change password</a></li>  
	            </ul>
	        </div>
	        <div id="main-cont">
	        	<div id="regist_form">
	        	<form method="post" action="finance/staff_infoModifyInput.jsp" name="staffadd" onSubmit="return checkdata()">
	        		<input type="hidden" name="action" value="changeinfo"/>
	            	<h2>Change a Finance</h2>
	            	<table>	            		
	                	<tr><td>User Name: </td><td><input name="username" value="<%=s.getUsername()%>" type="text" onblur = "checkUserName(this.value)"/>
	                	<span id = "usernameErr"></span><br></td></tr>      
	                    <tr><td>Name: </td><td><input name="name" value = "<%=s.getName() %>" type="text"  onblur = "checkName(this.value)"/>
	                    <span id = "nameErr"></span><br></td></tr>
	                    <tr><td>ID Card: </td><td><input name="idcard" type="text" value = "<%=s.getIdcard() %>" onblur = "checkid(this.value)"/>
	                    <span id = "idErr"></span><br></td></tr>
	                    <tr><td>Department No: </td><td> <%=s.getDeptno() %></td></tr>
	                    <tr><td>Job: </td><td><%=s.getJob() %></td></tr>
	                    <tr><td>Salary: </td><td><%=s.getSal() %></td></tr>	                    
	                    <tr><td>Manager: </td><td><%=s.getMgr() %></td></tr>
	                    <tr><td/><td/></tr>      
	              
	                </table>
	                <center><input name="regsubmit" type="submit" value="OK! Change The Staff"/></center>
	            </form>
	        </div>
	        </div>
	    </div>
	    <!-- // contents -->
	</div>
	<!-- // container -->
	<div id="footer">
		<div id="bs_stdio">
	    	©2011-2011 www.bluesky.com.mo All Rights Reserved<br/>
	    	<img src="images/bluesky_logo.png" />
	    </div>
	</div>
  </body>
</html>
